package lesson02;

public class Demo_203 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread2=new Thread(()-> {
            for(int i=0;i<8;i++){

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName()+66666);
            }

        },"我是一个线程");
//查看的是PCB是否存活，而不是thread对象
        System.out.println(thread2.isAlive());
        System.out.println(thread2.getState());
        thread2.start();
        Thread.sleep(500);//休眠一会再查看线程状态大概率是休眠的，因为这个线程大部分时间处于休眠状态TIMED_WAITING
        System.out.println(thread2.isAlive());
        System.out.println(thread2.getState());
        thread2.join();
        System.out.println(thread2.isAlive());
        System.out.println(thread2.getState());
//        for(Thread.State state:Thread.State.values()){
//            System.out.println(state);
//        }
    }
}
